﻿using System;

namespace XExcel.Validations
{
    public class FunctionValidate : Validate
    {
        public Func<object, bool> Valid { get; }

        public FunctionValidate(Func<object, bool> valid, string message = null)
        {
            Valid = valid;
            Message = message ?? "验证失败";
        }

        public override bool Test(object val)
        {
            return Valid?.Invoke(val) == true;
        }
    }
}
